function type(obj) {
	// 深拷贝
	const toString = Object.prototype.toString
	const map = {
		'[object Boolean]': 'boolean',
		'[object Number]': 'number',
		'[object String]': 'string',
		'[object Function]': 'function',
		'[object Array]': 'array',
		'[object Date]': 'date',
		'[object RegExp]': 'regExp',
		'[object Undefined]': 'undefined',
		'[object Null]': 'null',
		'[object Object]': 'object',
	}
	return map[toString.call(obj)]
}

export function cloneDeep(data) {
	// 深拷贝
	const t = type(data)
	let o
	let i
	let ni
	if (t === 'array') {
		o = []
	} else if (t === 'object') {
		o = {}
	} else {
		return data
	}
	if (t === 'array') {
		for (i = 0, ni = data.length; i < ni; i++) {
			o.push(cloneDeep(data[i]))
		}
		return o
	} else if (t === 'object') {
		// eslint-disable-next-line guard-for-in
		for (i in data) {
			o[i] = cloneDeep(data[i])
		}
		return o
	}
}